<div id="foo" style="font-size:40px;">{$msg}</div>
<a style="width:200px;height:150px;font-size:40px;" class="copyBtn" href="javascript:;" data-clipboard-action="copy" data-clipboard-target="#foo">复制</a>

<script type='text/javascript' src="https://cdn.staticfile.org/clipboard.js/1.5.15/clipboard.min.js"></script>
<script>
    var clipboard = new Clipboard('.copyBtn').on('success', function(e) {alert("复制成功");
        var e = e || window.event;
        console.log(e);
    }).on('error', function(e) {alert("复制失败")});
</script>